package WaiBao;

import java.util.Arrays;

public class ZhangShuiQin {
    public static void main(String[] args) {
        String[] name= {"张无忌(班长)", "张三丰(副班长)", "小李(学习委员)", "林青霞(文艺委员)", "孙悟空", "李文宁", "徐宁宁", "沙和尚", "张小青", "杨考考", "张晓", "牛魔王",
                "芭蕉公主", "李道琼", "郭晓航", "张静文", "张晓", "贺精明", "核桃", "锤子", "铆钉", "砖头", "房东", "戴雨桐", "林泽凯", "李文凯", "郝忠泽", "王境泽",
                "王浩楠", "张水清(学生)"};//考生本人:杨鑫润(学生)
        int[] age = {22, 21,19,20,20, 18, 21,22,18, 22,19,19, 21, 18, 21,20, 21, 20, 20, 19, 19,21, 21, 21, 20, 23, 19,22,21, 21};//考生年龄：21岁

        double[] score1 = {99, 75, 89, 85, 74, 78, 71, 80, 68, 80, 94, 77, 85, 59, 64, 68, 69, 69, 96, 80, 92, 91, 90, 85, 75, 84, 76, 88, 84, 94};
        double[] score2 = {60, 92, 84, 86, 76, 86, 74, 73, 61, 74, 84, 67, 84, 75, 95, 65, 86, 71, 66, 78, 82, 71, 85, 87, 75, 84, 75, 74, 87, 93};
        double[] score3 = {71, 83, 79, 74, 85, 75, 63, 69, 80, 69, 73, 87, 85, 85, 65, 98, 89, 73, 96, 63, 92, 81, 95, 85, 76, 81, 74, 71, 75, 95};

        double tiantian1;//代表每个学生的总分
        double tiantian2;//代表每个学生的平均分
//        for (int i = 0; i < 30; i++) {
//            tiantian1 =  score1[i] + score2[i] + score3[i];
//            tiantian2 = (tiantian1 * 1.0) / 3;
//            System.out.println(name[i] + "的总分为:" +tiantian1);
//            System.out.println(name[i] + "的平均分为:" + tiantian2);
//        }


        double fly1 = 0, fly2 = 0;
        double[] array1 = new double[30];
//        for (int i = 0; i < 30; i++) {
//            fly1 = score1[i] +  score2[i] + score3[i];
//            fly2  = (fly1 * 1.0) / 3;
//            array1[i] =  fly2;
//        }
//
//        for (int i = 0; i <array1.length - 1; i++) {
//            for (int j = 0; j < array1.length - i - 1; j++) {
//                if (array1[j] < array1[j + 1]) {
//                    double tep =array1[j];
//                    array1[j] =array1[j + 1];
//                    array1[j + 1] = tep;
//                }
//            }
//        }
//        System.out.println("前十名同学的成绩为:");
//        for (int i = 0; i < 10; i++) {
//            System.out.println(array1[i]);
//        }


        double pifu1 = 0,pifu2 = 0, pifu3 = 0;//计算每门课的平均分
        double hebei1 = 0,hebei2 = 0,hebei3 = 0;//计算每门课标准差
        double hunan1 = 0, hunan2 = 0,hunan3 = 0;//计算每门课中位数
        double sap = 0;
        for (int i = 0; i < score1.length; i++) {
            sap+=score1[i];
        }
        pifu1 = (sap*1.0)/30;
        System.out.println("分析化学的班级平均分为:"+ pifu1);
        double Sum = 0;
        for (int i = 0; i < score2.length; i++) {
            Sum+=score2[i];
        }
        pifu2 = (Sum*1.0)/30;
        System.out.println("线性代数的班级平均分为:"+pifu2);
        double sum = 0;
        for (int i = 0; i <score3.length; i++) {
            sum+=score3[i];
        }
        pifu3 = (sum*1.0)/30;
        System.out.println("有机化学的班级平均分为:"+pifu3);




        double c1 = 0,c2 = 0,c3 = 0;
        for (int i = 0; i <score1.length; i++) {
            c1+= (score1[i] - pifu1)*(score1[i] - pifu1);
        }
        hebei1 = Math.sqrt(c1*1.0/30);
        System.out.println("分析化学的班级标准差为:"+hebei1);

        for (int i = 0; i <score2.length; i++) {
            c2+= (score2[i] - pifu2)*(score2[i] -pifu2);
        }
        hebei2 = Math.sqrt(c2*1.0/30);
        System.out.println("线性代数的班级标准差为:"+hebei2);

        for (int i = 0; i <score3.length; i++) {
            c3+= (score3[i] - pifu3)*(score3[i] -pifu3);
        }
        hebei3 = Math.sqrt(c3*1.0/30);
        System.out.println("有机化学的班级标准差为:"+hebei3);
////////////
//////////
//////////
        Arrays.sort(score1);
        Arrays.sort(score2);
        Arrays.sort(score3);
        hunan1 =( score1[14]+score1[15])*1.0/2;
        hunan2 =(score2[14]+score2[15])*1.0/2;
        hunan3 =( score3[14]+score3[15])*1.0/2;
        System.out.println("分析化学的中位数为:"+ hunan1);
        System.out.println("线性代数的中位数为:"+ hunan2);
        System.out.println("有机化学学的中位数为:"+ hunan3);

    }
}
